/**
 * 
 */
package net.udp;

import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

/**
 * @author wangjg
 * 
 */
public class MulticastServer {
	public static void main(String[] arstring) {
		try {
			System.out.println("server is running...");
			MulticastSocket multicastSocket = new MulticastSocket(7777);
			InetAddress inetAddress = InetAddress.getByName("230.0.0.1");
			multicastSocket.joinGroup(inetAddress);
			while (true) {
				byte[] arb = new byte[100];
				DatagramPacket datagramPacket = new DatagramPacket(arb, arb.length);
				multicastSocket.receive(datagramPacket);
				System.out.println(new String(arb));
			}
		} catch (Exception exception) {
			exception.printStackTrace();
		}
	}
}
